import request from '@/utils/request'

// 获取公告列表（分页）
export function page(title, status, beginTime, endTime, page, size) {
  return request({
    url: '/announcements',
    method: 'get',
    params: {
      title,
      status,
      beginTime,
      endTime,
      page,
      size
    }
  })
}

// 添加公告
export function add(announcement) {
  return request({
    url: '/announcements',
    method: 'post',
    data: announcement
  })
}

// 更新公告
export function update(announcement) {
  return request({
    url: '/announcements',
    method: 'put',
    data: announcement
  })
}

// 根据ID删除公告
export function deleteById(id) {
  return request({
    url: '/announcements/' + id,
    method: 'delete'
  })
}

// 批量删除公告
export function batchDelete(ids) {
  return request({
    url: '/announcements/' + ids,
    method: 'delete'
  })
}

// 根据ID查询公告
export function selectById(id) {
  return request({
    url: '/announcements/' + id,
    method: 'get'
  })
}

// 更新公告状态
export function updateStatus(id, status) {
  return request({
    url: `/announcements/${id}/status/${status}`,
    method: 'put'
  })
} 
